<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width:600px; margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire" title="更改时间"></i>&nbsp;&nbsp;更改时间</h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/${pagetype}-rounds/${courseRoundId}/schedules/${roundCode}/time" data-validate="true">

     <input type="hidden" name="_method" value="PATCH">
     <input type="hidden" name="dayhour" value="${dayhour}">
    
      <div class="modal-body">
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">日期:</label>
          <div class="pull-left col-xs-6">
            <input type="text" class="form-control date" name="day" value="${schedule.occurDate}" data-validate="required"/>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label text-right">时间:</label>
          <div class="pull-left col-xs-6">
            <select name="hour" class="form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="hour" items="${site.appointTimes}">
                <c:set var="hours" value="${fn:split(hour, ':')}"/>
                <option value="${hour}" ${schedule.occurHour eq hour ? 'selected' : ''}>hour ~ ${hours[0] + 1}:${hours[1]}</option>
              </c:forEach>
              <%-- <c:forEach begin="${site.appointStart[0]}" end="${site.appointEnd[0]-1}" varStatus="status">
                <c:set var="hour" value="${status.index}:00"></c:set>
                <c:set var="halfhour" value="${status.index}:30"></c:set>
                <c:choose>
                  <c:when test="${status.index == site.appointStart[0] and site.appointStart[1] == '30'}">
                    <option value="${halfhour}" ${schedule.occurHour eq halfhour ? 'selected' : ''}>${status.index}:30 ~ ${status.index + 1}:30</option>
                  </c:when>
                  <c:when test="${status.index == site.appointEnd[0]-1 and site.appointEnd[1] == '00'}">
                    <option value="${hour}" ${schedule.occurHour eq hour ? 'selected' : ''}>${status.index}:00 ~ ${status.index + 1}:00</option>
                  </c:when>
                  <c:otherwise>
                    <option value="${hour}" ${schedule.occurHour eq hour ? 'selected' : ''}>${status.index}:00 ~ ${status.index + 1}:00</option>
                    <option value="${halfhour}" ${schedule.occurHour eq halfhour ? 'selected' : ''}>${status.index}:30 ~ ${status.index + 1}:30</option>
                  </c:otherwise>
                </c:choose>
              </c:forEach> --%>
            </select>
          </div>
        </div>
      </div>
      
      <div class="modal-footer clearfix">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>

<script type="text/javascript">
 
  $('.date').datetimepicker({
     format: 'yyyy-mm-dd',
     autoclose: true,
     language: 'zh-CN',
     todayBtn: 'linked',
     startDate: '${today}',
     todayHighlight: true,
     pickerPosition: 'bottom-right',
     minView: 'month'
   })
  
  $('select[name="hour"]').select2({
    placeholder : '请选择具体时间段',
    minimumResultsForSearch : 5,
    allowClear : true,
  });
  
</script>
